package com.soft.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.soft.common.annotation.Log;
import com.soft.common.core.controller.BaseController;
import com.soft.common.core.domain.AjaxResult;
import com.soft.common.enums.BusinessType;
import com.soft.manage.domain.TemplateMessage;
import com.soft.manage.service.ITemplateMessageService;
import com.soft.common.utils.poi.ExcelUtil;
import com.soft.common.core.page.TableDataInfo;

/**
 * 模板信息Controller
 *
 * @author mobin
 * @date 2025-06-02
 */
@RestController
@RequestMapping("/manage/templateMessage")
public class TemplateMessageController extends BaseController
{
    @Autowired
    private ITemplateMessageService templateMessageService;

    /**
     * 查询模板信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:templateMessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(TemplateMessage templateMessage)
    {
        startPage();
        List<TemplateMessage> list = templateMessageService.selectTemplateMessageList(templateMessage);
        return getDataTable(list);
    }

    /**
     * 导出模板信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:templateMessage:export')")
    @Log(title = "模板信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TemplateMessage templateMessage)
    {
        List<TemplateMessage> list = templateMessageService.selectTemplateMessageList(templateMessage);
        ExcelUtil<TemplateMessage> util = new ExcelUtil<TemplateMessage>(TemplateMessage.class);
        util.exportExcel(response, list, "模板信息数据");
    }

    /**
     * 获取模板信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:templateMessage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(templateMessageService.selectTemplateMessageById(id));
    }

    /**
     * 新增模板信息
     */
    @PreAuthorize("@ss.hasPermi('manage:templateMessage:add')")
    @Log(title = "模板信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TemplateMessage templateMessage)
    {
        return toAjax(templateMessageService.insertTemplateMessage(templateMessage));
    }

    /**
     * 修改模板信息
     */
    @PreAuthorize("@ss.hasPermi('manage:templateMessage:edit')")
    @Log(title = "模板信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TemplateMessage templateMessage)
    {
        return toAjax(templateMessageService.updateTemplateMessage(templateMessage));
    }

    /**
     * 删除模板信息
     */
    @PreAuthorize("@ss.hasPermi('manage:templateMessage:remove')")
    @Log(title = "模板信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(templateMessageService.deleteTemplateMessageByIds(ids));
    }
}
